const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})
const db = cloud.database();
const dayjs = require('dayjs');
const ResponseDTO = require('./res');
// 情侣关系表
const COUPLE = 'cloud_couples'; 
const USER = 'edu-cloud-users';

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  let openid = wxContext.OPENID;
  let userRes = await db.collection(USER).where({
    openid
  }).get();
  if(userRes.data.length == 0){
    return ResponseDTO.wrap(404,"未找到用户信息");
  }else{
    return ResponseDTO.succData(userRes.data[0])
  }
}